package com.cn.entity;

import java.util.Date;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

/**
 * 短信记录
 * @author zlei
 *
 */
@Entity
@Table(name="smsrecord")
@GenericGenerator(name = "system-uuid",strategy = "uuid")
@Cacheable
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SMSRecord {
	/**
	 * id
	 */
	@Id
	@GeneratedValue(generator="system-uuid")
	@Column(name="smsRecordID",length=32)
	private String smsRecordID;
	
	/**
	 * 使用发送的运营商名称
	 */
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinColumn(name = "smsOperatorName")
	private SMSOperator smsOperator;

	/**
	 * 运营商消息唯一识别码
	 */
	@Column(name = "operatorMessageID")
	private String operatorMessageID;

	/**
	 * 发送号码
	 */
	@Column(name="sendNumber")
	private String sendNumber;
	
	/**
	 * 发送内容
	 */
	@Column(name="sendContent")
	private String sendContent;
	
	/**
	 * 创建时间
	 */
	@Column(name="createDate")
	private Date createDate;
	/**
	 * 修改时间
	 */
	@Column(name ="updateDate")
	private Date updateDate;
	/**
	 * 发送状态 0：正在发送 ：1：发送成功 2：发送失败 3:等待发送
	 */
	@Column(name="sendState")
	private String sendState;
	
	/**
	 * ip来源
	 */
	@Column(name="fromIP")
	private String fromIP;
	/**
	 * 对应的业务
	 */
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER)
	@JoinColumn(name = "businessRecordId")
	private SMSBusiness businessRecord;
	/**
	 * ID
	 * @return
	 */
	public String getSmsRecordID() {
		return smsRecordID;
	}
	/**
	 * ID
	 * @return
	 */
	public void setSmsRecordID(String smsRecordID) {
		this.smsRecordID = smsRecordID;
	}
	/**
	 * 发送号码
	 * @return
	 */
	public String getSendNumber() {
		return sendNumber;
	}
	/**
	 * 使用发送的运营商名称
	 * @return
	 */
	public SMSOperator getSmsOperator() {
		return smsOperator;
	}
	/**
	 * 使用发送的运营商名称
	 * @return
	 */
	public void setSmsOperator(SMSOperator smsOperator) {
		this.smsOperator = smsOperator;
	}
	/**
	 * 发送号码
	 */
	public void setSendNumber(String sendNumber) {
		this.sendNumber = sendNumber;
	}

	/**
	 * 运营商消息唯一识别码
	 */
	public String getOperatorMessageID() {
		return operatorMessageID;
	}

	/**
	 * 运营商消息唯一识别码
	 */
	public void setOperatorMessageID(String operatorMessageID) {
		this.operatorMessageID = operatorMessageID;
	}

	/**
	 * 创建时间
	 * @return
	 */
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	/**
	 * 创建时间
	 * @return
	 */
	public Date getCreateDate() {
		return createDate;
	}
	/**
	 * 修改时间
	 * @return
	 */
	public Date getUpdateDate() {
		return updateDate;
	}
	/**
	 * 修改时间
	 * @return
	 */
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	/**
	 * 发送内容
	 * @return
	 */
	public String getSendContent() {
		return sendContent;
	}
	/**
	 * 发送内容
	 * @return
	 */
	public void setSendContent(String sendContent) {
		this.sendContent = sendContent;
	}
	/**
	 * 发送状态
	 * @return
	 */
	public String getSendState() {
		return sendState;
	}
	/**
	 * 发送状态
	 * @return
	 */
	public void setSendState(String sendState) {
		this.sendState = sendState;
	}
	/**
	 * 对应的业务代码
	 * @return
	 */
	public SMSBusiness getBusinessRecord() {
		return businessRecord;
	}

	/**
	 * 对应的业务代码
	 * @return
	 */
	public void setBusinessRecord(SMSBusiness businessRecord) {
		this.businessRecord = businessRecord;
	}
	/**
	 * 构造方法
	 * @param smsRecordID
	 * @param smsOperator
	 * @param sendNumber
	 * @param sendContent
	 * @param createDate
	 * @param updateDate
	 * @param sendState
	 * @param businessRecord
	 */
	public SMSRecord(String smsRecordID, SMSOperator smsOperator,
			String sendNumber, String sendContent, Date createDate,
			Date updateDate, String sendState, SMSBusiness businessRecord) {
		super();
		this.smsRecordID = smsRecordID;
		this.smsOperator = smsOperator;
		this.sendNumber = sendNumber;
		this.sendContent = sendContent;
		this.createDate = createDate;
		this.updateDate = updateDate;
		this.sendState = sendState;
		this.businessRecord = businessRecord;
	}
	
	
	/**
	 * 构造方法
	 * @param smsOperator
	 * @param operatorMessageID
	 * @param sendNumber
	 * @param sendContent
	 * @param createDate
	 * @param updateDate
	 * @param sendState
	 * @param fromIP
	 * @param businessRecord
	 */
	public SMSRecord(SMSOperator smsOperator, String operatorMessageID,
			String sendNumber, String sendContent, Date createDate,
			Date updateDate, String sendState, String fromIP,
			SMSBusiness businessRecord) {
		super();
		this.smsOperator = smsOperator;
		this.operatorMessageID = operatorMessageID;
		this.sendNumber = sendNumber;
		this.sendContent = sendContent;
		this.createDate = createDate;
		this.updateDate = updateDate;
		this.sendState = sendState;
		this.fromIP = fromIP;
		this.businessRecord = businessRecord;
	}
	public SMSRecord() {
		this.createDate= new Date();
		this.updateDate = new Date();
	}
	public String getFromIP() {
		return fromIP;
	}
	public void setFromIP(String fromIP) {
		this.fromIP = fromIP;
	}
	
	
	
}
